<%@ page language="java" contentType="text/html; charset=UTF-8"
	pageEncoding="UTF-8"%>
<%@page import="com.doone.telmarket.domain.ibator.ServiceTypeExample"%>
<%@page import="com.doone.telmarket.domain.ibator.ServiceType"%>
<%@page import="com.doone.telmarket.domain.Service"%>
<%@ taglib prefix="se" uri="/WEB-INF/serviceTypeTag.tld"%>
<%
response.addHeader("Cache-Control", "no-cache");
response.addHeader("Expires", "Thu, 01 Jan 1970 00:00:01 GMT");
%>
<%

	ServicePage spage = (ServicePage)session.getAttribute("servicePage");
String redirectUrl = spage.getServiceOrder().getRedirectUrl();
if(redirectUrl==null){
	redirectUrl = "http://";
}

%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">



<%@page import="java.util.List"%>
<%@page import="java.util.ArrayList"%>
<%@page import="com.doone.telmarket.domain.ServiceProduct"%>
<%@page import="com.doone.telmarket.domain.ServicePage"%>
<%@page import="java.util.Map"%>
<%@page import="java.util.HashMap"%>
<%@page import="com.doone.telmarket.domain.ServicePageContent"%>
<%@page import="java.math.BigDecimal"%><html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
<title>main</title>
<link rel="stylesheet" rev="stylesheet"
	href="${pageContext.request.contextPath}/css/admin/style-admin.css"
	type="text/css" media="all" />
<script type="text/javascript"
	src="${pageContext.request.contextPath}/ckeditor/ckeditor.js"></script>
<script type="text/javascript"
	src="${pageContext.request.contextPath}/ckeditor/ckeditor.js"></script>

<script src="${pageContext.request.contextPath}/js/jquery.js"
	type="text/javascript"></script>
<script
	src="${pageContext.request.contextPath}/js/jquery.ui.draggable.js"
	type="text/javascript"></script>
<script src="${pageContext.request.contextPath}/js/jquery.alerts.js"
	type="text/javascript"></script>
<script src="${pageContext.request.contextPath}/js/ajaxfileupload.js"
	type="text/javascript"></script>
<script src="${pageContext.request.contextPath}/js/serviceOpration.js"
	type="text/javascript"></script>
<link href="${pageContext.request.contextPath}/css/jquery.alerts.css"
	rel="stylesheet" type="text/css" media="screen" />
	<script src="${pageContext.request.contextPath}/fckeditor/fckeditor.js"
	type="text/javascript"></script>
<style type="text/css">

.file{border:1px solid #333333;color:#666666;background:#eeeeee;font:normal 12px Tahoma;height:18px}
</style>





<script type="text/javascript">
	$(document).ready(function(){
		
		//CKEDITOR.replace('serviceContent');
		var contextPath = $("#contextPath").val();

		CKEDITOR.replace('serviceContent',{
			filebrowserImageUploadUrl:contextPath+'/admin/upload-image',
			filebrowserFlashUploadUrl:contextPath+'/admin/upload-flash'
		});
		$("#query").click(function(){
			$("#serviceDiv").children().remove();
			$("#editor").css("display","none");
			$.ajax({
			    url: 'getServiceByType?serviceType='+$("#serviceType").val()+'&serviceClassify='+$("#serviceClassify").val(),
			    type: 'POST',
			    timeout: 5000,
			    error: function(){
			        jAlert('获取数据失败','消息');
			    },
			    success: function(msg){
			        if(msg!=""){
			        	eval('var obj='+msg);
			        	serviceList = obj;
			        	if(obj.length==0){
			        		var div1 = $('<div id=div1>  没有数据</div>');
			        		$("#serviceDiv").append(div1);
					    }else{
				        	for(var i=0;i<obj.length;i++){
					        	var div1 = $('<div></div>');
				        		
				        		div1.append("<div style='float:left;width:200px;'>"+obj[i].serviceName+"</div>");
				        		div1.append("<div style='float:left;width:50px; cursor: hand'><a onclick='modifyService("+obj[i].serviceCode
						        		+")'>编辑</a></div>");
				        		div1.append("<div style='float:left;width:50px; cursor: hand' id='"+obj[i].serviceCode+"'><a onclick='deleteById("+obj[i].serviceCode
						        		+")'>删除</a></div><br>");
				        		$("#serviceDiv").append(div1);
				        	}
			        	}
				    }
			    }
			});
		});

		$("#serviceType option[value='<%=spage.getService().getServiceType().getServiceTypeId() %>']").attr("selected",true);
		$("#serviceClassify option[value='<%=spage.getService().getServiceClassify().getServiceClassifyId() %>']").attr("selected",true);
    	$("#orderMode option[value='<%=spage.getServiceOrder().getOrderMode() %>']").attr("selected",true);
    	$("#grade option[value='<%=spage.getRecommandGrade() %>']").attr("selected",true);
		});
		function getServiceById(value){

			alert(value);
			var serviceId = document.getElementById("serviceQueryId").value=value;
			var form = document.getElementById("serviceIdForm");
			form.submit();
		}

		
	
   </script>
</head>
<body>
<div style="z-index: 1;height: 1000"> <input  type="hidden" id="contextPath" value="${pageContext.request.contextPath}">

<div class="MainDiv">
<table width="99%" border="0" cellpadding="0" cellspacing="0"
	class="CContent">
	<tr>
		<th class="tablestyle_title">增值业务管理</th>
	</tr>
	<tr>
		<td class="CPanel">
		<table border="0" cellpadding="0" cellspacing="0" style="width: 100%">
			<tr>
				<td align="left">&nbsp;&nbsp;&nbsp;<a href="${pageContext.request.contextPath}/admin/service/service.jsp">新增增值业务</a>
				<a href="${pageContext.request.contextPath}/admin/service/toOperationService.jsp">编辑增值业务</a></td>
			</tr>



			<tr align="center">
				<td class="TablePanel"></td>
			</tr>
			<tr>
				<TD width="100%">
				<form action="${pageContext.request.contextPath}/admin/updateService?saveType=update" method="post" id="serviceform">
				<fieldset style="height: 100%;" id="editor" ><legend>编辑增值业务(带*的为必填)</legend>
				<table border="0" cellpadding="2" cellspacing="1"
					style="width: 100%">
					<tr>
						<td nowrap align="right" width="13%">订购方式:</td>
						<td width="32%">&nbsp;<select name="orderMode" id="orderMode">
								<option value="ISM">ISMP平台</option>
								<option value="CRM">CRM平台</option>
								<option value="RDT">直接跳转</option>
								<!--  	<option value="SSO">单点认证</option>-->
							</select>
						</td>
					</tr>
					<tr>
						<td nowrap align="right" width="13%">URL:</td>
						<td width="32%">&nbsp;<input type="text" maxlength="30" 
							name="orderUrl" id="orderUrl" value="<%=redirectUrl %>"><span style="color:black">*</span></td>
					</tr>
					<tr>
						<td nowrap align="right" width="13%">增值业务名称:</td>
						<td width="32%">&nbsp;<input type="text" maxlength="30" 
							name="serviceName" id="serviceName" value="<%=spage.getService().getServiceName() %>"><input type="hidden" maxlength="30" 
							name="serviceId" id="serviceId" value="<%=spage.getServiceCode() %>" /><span style="color:black">*</span></td>
					</tr>
					<tr>
						<td nowrap align="right" width="13%">增值服务类别:</td>
						<td width="32%">&nbsp;<se:showServiceType/>
						</td>
					</tr>
					<tr>
						<td nowrap align="right" width="13%">增值功能类别:</td>
						<td width="32%">&nbsp;<se:showServiceClassify/></td>
					</tr>
					<tr>
						<td nowrap align="right" width="13%">增值业务服务提供商:</td>
						<td width="32%">&nbsp;<input type="text" name="spName" id="spname"  value="<%=spage.getService().getSpName() %>"><span style="color:black">*</span></td>
					</tr>
					
					<tr>
						<td nowrap align="right" width="13%">增值业务简要描述:</td>
						<td width="32%">&nbsp;<input type="text" name="serviceSummaryContent"
							id="serviceSummaryContent" size="30" value="<%=spage.getServiceSummaryContent() %>"><span style="color: black">*</span></td>
					</tr>
					
					<tr>
						<td nowrap align="right" width="13%">增值业务缩略图(点击更改):</td>
						<td width="32%">&nbsp;<img id="small" onclick="showSmallUpload();" src="${pageContext.request.contextPath}//<%=spage.getPageSmallIconPath() %>"  style="cursor: hand"/>请选择JPG,GIF,PNG格式的图片上传.宽度(大于80px,小于100px).高度(大于55px,小于75px)</td>
					</tr>
					<tr>
						<td nowrap align="right" width="13%">增值业务LOGO图(点击更改):</td>
						<td width="32%">&nbsp;<img id="logo" onclick="showLogoUpload();"  src="${pageContext.request.contextPath}/<%=spage.getPageLogoPath() %>"   style="cursor: hand"/><span style="color:black">请选择JPG,GIF,PNG格式的图片上传.宽度(大于170px,小于250px).高度(大于167px,小于200px)</span></td>
					</tr>
					<tr>
						<td nowrap align="right" width="13%">增值业务FLASH:</td>
						<td width="32%">&nbsp;<input type="button" class="button" onclick="window.open('${pageContext.request.contextPath}/admin/service/showFlash.jsp');"  value="查看" ></a>
						<input type="button" class="button" onclick="showFlashUpload();"  value="更改" >
						<span style="color:black">请选择小于10M的SWF格式的FLASH文件上传</span></td>
					</tr>
				</table>
				<br />
				
				<table border="0" cellpadding="2" cellspacing="1"
					style="width: 100%">
					<tr><td nowrap align="right" width="13%">增值业务推荐星级:</td>
						<td width="32%">&nbsp;<select name="serviceCodeGrade"  id="grade">
							<option value="1">&nbsp;1&nbsp;</option>
							<option value="2">&nbsp;2&nbsp;</option>
							<option value="3">&nbsp;3&nbsp;</option>
							<option value="4">&nbsp;4&nbsp;</option>
							<option value="5">&nbsp;5&nbsp;</option>
						</select>星</td>
					</tr>
				<TR>
					<TD colspan="2" align="center" height="50px"><input type="button"
						value="保存" class="button" onclick="saveService();" /> <a href="toOperationService.jsp"><input type="button" name="Submit2"
						value="返回" class="button" onclick="window.history.go(-1)" /></a></TD>
				</TR>
				</table>
				</fieldset>
				</form>
			<fieldset style="height: 100%;" id="editorDesc" ><legend>编辑增值业务介绍信息</legend>
				
				<table border="1px" id="serviceDescTable">
					<tr>
						<td width="150px">标题</td>
						<td width="724px">内容</td>
						<td width="50px">操作</td>
					</tr>
					<%
							  	if(session.getAttribute("servicePage")!=null){
							  		 List<ServicePageContent> sc = ((ServicePage)session.getAttribute("servicePage"))
							  		 				.getContents();
							  		 for(int i=0;i<sc.size();i++){
							  			 %>  
							  			 
							  	<tr>
							    <td width="150"><%=sc.get(i).getTitle() %></td>
							    <td width="150"><%=sc.get(i).getContent() %></td>
							    <td width="50"><input type=button class=button onclick=deleteContent('<%=sc.get(i).getTitle() %>',this); value=删除 /></td>
							   </tr>		 
							  			 <%
							  		 }
							  	}
							   
							  %>
				</table>
				<input type="button"
						value="新增" class="button" onclick="showEditor();"/>
			</fieldset>
			
			<fieldset style="height: 100%;" id="editor2" ><legend>编辑增值业务产品信息</legend>
				<table border="1px" id="serviceProductTable">
					<tr>
						<td width="100px">类别代码</td>
						<td width="100px">类别名称</td>
						<td width="250px">支持终端</td>
						<td width="80px">产品资费</td>
						<td width="80px">编码类别</td>
						<td width="50px">操作</td>
					</tr>
					<%
							  	if(session.getAttribute("servicePage")!=null){
							  		 List<ServiceProduct> sp = ((ServicePage)session.getAttribute("servicePage"))
							  		 				.getService().getProducts();
							  		 for(int i=0;i<sp.size();i++){
							  			 String type = "套餐类型";
							  			 if(sp.get(i).getProductType().toString().equals("P")){
							  				type =  "产品类型";
							  			 }
							  			 %>  
							  			 
							  	<tr>
							    <td width="150"><%=sp.get(i).getProductId() %></td>
							    <td width="150"><%=sp.get(i).getProductName() %></td>
							    <td width="150"><%=sp.get(i).getProductSummary() %></td>
							    <td width="100"><%=sp.get(i).getCost().divide(new BigDecimal(100)) %></td>
							    <td width="150"><%=type %></td>
							    <td width="50"><input type=button class=button onclick="deleteProduct('<%=sp.get(i).getProductId() %>',this);" value=删除 /></td>
							   </tr>		 
							  			 <%
							  		 }
							  	}
							   
							  %>
				</table>
				<input type="button"
						value="新增" class="button" onclick="showProductEditor();"/>
			</fieldset>
				</TD>
			</TR>

		</TABLE>


		</td>
	</tr>
	<TR>
		<TD colspan="2" align="center" height="50px"></TD>
	</TR>
</TABLE>
</div></div>

<div id="bgLayer" style="float:left;position:absolute;background:#CCCCCC;left:0px;top:0px;width:100%;height:1000;filter:alpha(style=0,opacity=50);display:none;z-index:2;"></div>
<div id="Layer1"  style=" display:none; border:0;background-image: url(/images/3Gsjj.jpg);position:absolute;top:1px; left:1px; width:528px; height:426px; z-index:3; text-align:left" >

    <div style="width: 760px;border-color: red;border: 1px solid;background-color: white;">
  <fieldset>
  	<legend>增加增值业务详细信息</legend>
  	
  	<table>
  	<tr>
  		<td>
  		　标题:　<input type="text" id="descTitle" name="descriptionName" maxlength="6">
  		</td>
  	</tr>
  		<tr>
			<td width="32%">&nbsp;&nbsp;内容：<br/>
				<textarea rows="3" cols="5" name="serviceContent" id="serviceContent"></textarea>
			</td>
		</tr>
		<TR>
		<TD colspan="2" align="center" height="50px"><input type="button"
			value="保存" style="cursor: hand" onclick="submitText()" class="button" /> <input type="button" name="Submit2"
			value="返回" style="cursor: hand" class="button" onclick="hideEdit();" />
			</TD>
	</TR>
  	</table>
  </fieldset>
  	
  </div>

</div>


<div id="Layer2"  style=" display:none; border:0;background-image: url(/images/3Gsjj.jpg);position:absolute;top:1px; left:1px; width:528px; height:70px; z-index:3; text-align:left" >

  <div style="width: 450px;border-color: red;border: 1px solid;background-color: white;height: 300px">
  	<fieldset ><legend>增加增值业务产品类别</legend>
					<table border="0" cellpadding="2" cellspacing="1"
						style="width: 100%">
						
						<tr>
							<td nowrap align="right" width="13%">类别代码：</td>
							<td width="32%"><input type="text" maxlength="30" 
								 id="productId" /><span style="color:black">*　 </span></td>
						</tr>
						<tr>
							<td nowrap align="right" width="13%">类别名称:</td>
							<td width="32%">
								<input type="text" id="productName">
							</td>
					　　</tr>
					    <tr>
							<td nowrap align="right" width="13%">支持终端:</td>
							<td width="32%">
								<input type="text" id="productDesc">
							</td>
					　　</tr>
					    <tr>
							<td nowrap align="right" width="13%">产品资费:</td>
							<td width="32%">
								<input type="text" id="productFee">元/月
							</td>
					　　</tr>
						<tr>
							<td nowrap align="right" width="13%">增值编码类别:</td>
							<td width="32%"><select name="serviceCodeType" id="serviceCodeType">
								<option value="P">产品类型</option>
								<option value="C">套餐类型</option>
							</select></td>
						</tr>
						<tr>
								<td colspan="2" align="center" height="50px"><input type="button" id="proSub" onclick="subPro();"
									value="保存" class="button"　/><input type="button" name="Submit2" id="proCancel"
									value="取消" class="button" onclick="hideProductEdit();"/>
								</td>
						</tr>
					</table>
					</fieldset>
  </div>
</div>


<div id="Layer3"  style=" display:none; border:0;background-image: url(/images/3Gsjj.jpg);position:absolute;top:1px; left:1px; width:528px; height:70px; z-index:3; text-align:left" >

  <div style="width: 450px;border-color: red;border: 1px solid;background-color: white;height: 130px">
  <fieldset>
  	<legend>上传增值业务缩略图</legend>
  	<table>
  	<tr>
  		<td>
  		　请选择：<input type="file" name="uploadFile" id="smallImage1">
  		<input type="button"  class="button" id="smallImageUpload" onclick="uploadSmallIcon();" value="上传">
  		<input type="button" onclick="displaySmallDiv();" class="button"  value="取消"　>
  		</td>
  		<td>
  		</td>
  	</tr>
  	</table>
  </fieldset>
  	
  </div>

</div>

<div id="Layer4"  style=" display:none; border:0;background-image: url(/images/3Gsjj.jpg);position:absolute;top:1px; left:1px; width:528px; height:70px; z-index:3; text-align:left" >

  <div style="width: 450px;border-color: red;border: 1px solid;background-color: white;height: 130px">
  <fieldset>
  	<legend>上传增值业务LOGO图</legend>
  	<table>
  	<tr>
  		<td>
  		　请选择：<input type="file" name="uploadFile" id="logoImage1">
  		<input type="button"  class="button" onclick="uploadLogoImage();" id="logoImageUpload" value="上传">
  		<input type="button" onclick="displayLogoDiv();" class="button" value="取消">
  		</td>
  		<td>
  		</td>
  	</tr>
  	</table>
  </fieldset>
  	
  </div>

</div>

<div id="Layer5"  style=" display:none; border:0;background-image: url(/images/3Gsjj.jpg);position:absolute;top:1px; left:1px; width:528px; height:70px; z-index:3; text-align:left" >

  <div style="width: 450px;border-color: red;border: 1px solid;background-color: white;height: 130px">
  <fieldset>
  	<legend>上传增值业务FLASH</legend>
  	<table>
  	<tr>
  		<td>
  		　请选择：<input type="file" name="uploadFile" id="flash1">
  		<input type="button" id="flashUpload"  onclick="uploadFlash();" class="button"  value="上传">
  		<input type="button" onclick="displayFlashDiv();" class="button" value="取消">
  		</td>
  		<td>
  		</td>
  	</tr>
  	</table>
  </fieldset>
  </div>
</div>
</body>
</html>